package com.ssh.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ssh.model.Contenttype;

public class ContenttypeDao extends HibernateDaoSupport implements IContenttypeDao {
	/* (non-Javadoc)
	 * @see com.ssh.dao.IContenttypeDao#save(com.ssh.model.Contenttype)
	 */
	@Override
	public void save(Contenttype ct) {
		try {
			getHibernateTemplate().save(ct);
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.ssh.dao.IContenttypeDao#delete(com.ssh.model.Contenttype)
	 */
	@Override
	public void delete(Contenttype ct) {
		try {
			getHibernateTemplate().delete(ct);
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.ssh.dao.IContenttypeDao#findById(java.lang.String)
	 */
	@Override
	public Contenttype findById(java.lang.String cid) {
		try {
			Contenttype ct = (Contenttype) getHibernateTemplate().get(
					"com.ssh.model.Contenttype", cid);
			return ct;
		} catch (RuntimeException re) {
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.ssh.dao.IContenttypeDao#findByExample(com.ssh.model.Contenttype)
	 */
	@Override
	public List<Contenttype> findByExample(Contenttype ct) {
		try {
			List<Contenttype> results = getHibernateTemplate().findByExample(ct);
			return results;
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.ssh.dao.IContenttypeDao#findByProperty(java.lang.String, java.lang.Object)
	 */
	@Override
	public List findByProperty(String propertyName, Object value) {
		try {
			String queryString = "from Contenttype as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.ssh.dao.IContenttypeDao#findAll()
	 */
	@Override
	public List findAll() {
		try {
			String queryString = "from Contenttype";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.ssh.dao.IContenttypeDao#attachDirty(com.ssh.model.Contenttype)
	 */
	@Override
	public void attachDirty(Contenttype ct) {
		try {
			getHibernateTemplate().saveOrUpdate(ct);
		} catch (RuntimeException re) {
			throw re;
		}
	}

}
